package ro.isdc.vms.vehicleadvertisement.dao.jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.simple.ParameterizedRowMapper;

import ro.isdc.vms.vehicleadvertisement.domain.VehicleAdvertisement;

/**
 * A Vehicle Advertisement JDBC row mapper.
 * @author Andrei Chirila / ISDC! Romania
 * @version 1.0.0
 * @date Jul 21, 2009
 */
public class VehicleAdvertisementMapper implements ParameterizedRowMapper<VehicleAdvertisement>{

  /**
   * {@inheritDoc}
   */
	public VehicleAdvertisement mapRow(final ResultSet rs, final int rowNo)
			throws SQLException {
		VehicleAdvertisement va = new VehicleAdvertisement();
		va.setVersionId(rs.getLong("VEHICLEADVERTVERSIONID"));
		va.setEntityId(rs.getLong("VEHICLEADVERTISEMENTID"));
		va.setVersionNo(rs.getInt("VEHICLEADVERTISEMENTVERSIONNO"));
		va.setDeletionTimestamp(rs.getTimestamp("DELETIONTIMESTAMP"));
		va.setAvailableFromDate(rs.getDate("AVAILABLEFROMDATE"));
		va.setAvailableToDate(rs.getDate("AVAILABLETODATE"));
		va.setDescription(rs.getString("DESCRIPTION"));
		va.setLifetimeStartDate(rs.getDate("LIFETIMESTARTDATE"));
		va.setCreationTimestamp(rs.getTimestamp("CREATIONTIMESTAMP"));
		va.setLastUpdateTimestamp(rs.getTimestamp("LASTUPDATETIMESTAMP"));
		va.setCreatedBy(rs.getLong("CREATEDBY"));
		va.setLastUpdatedBy(rs.getLong("LASTUPDATEDBY"));
		va.setFlaggedAsOld(rs.getBoolean("ISFLAGGEDASOLD"));
		return va;
	}

}
